@(account: gitbucket.core.model.Account,
  personalTokens: List[gitbucket.core.model.AccessToken],
  gneratedToken: Option[(gitbucket.core.model.AccessToken, String)])(implicit context: gitbucket.core.controller.Context)
@import context._
@import gitbucket.core.view.helpers._
@html.main("Applications"){
<div class="container body">
  <div class="row">
    <div class="col-md-3">
      @menu("application", settings.ssh)
    </div>
    <div class="col-md-9">
      <div class="panel panel-default">
        <div class="panel-heading strong">Personal access tokens</div>
        <div class="panel-body">
          @if(personalTokens.isEmpty && gneratedToken.isEmpty){
            No tokens.
          } else {
            Tokens you have generated that can be used to access the GitBucket API.
            <hr style="margin-top: 10px;">
          }
          @gneratedToken.map{ case (token, tokenString) =>
            <div class="alert alert-info">
              Make sure to copy your new personal access token now. You won't be able to see it again!
            </div>
            <a href="@path/@account.userName/_personalToken/delete/@token.accessTokenId" class="btn btn-sm btn-danger pull-right">Delete</a>
            <div style="width: 50%;">
              @helper.html.copy("generated-token-copy", tokenString){
                <input type="text" value="@tokenString" class="form-control input-sm" readonly>
              }
            </div>
            <hr style="margin-top: 10px;">
          }
          @personalTokens.zipWithIndex.map { case (token, i) =>
            @if(i != 0){
              <hr style="margin-top: 10px;">
            }
            <strong>@token.note</strong>
            <a href="@path/@account.userName/_personalToken/delete/@token.accessTokenId" class="btn btn-sm btn-danger pull-right">Delete</a>
          }
        </div>
      </div>
      <form method="POST" action="@path/@account.userName/_personalToken" validate="true">
        <div class="panel panel-default">
          <div class="panel-heading strong">Generate new token</div>
          <div class="panel-body">
            <fieldset>
              <label for="note" class="strong">Token description</label>
              <div><span id="error-note" class="error"></span></div>
              <input type="text" name="note" id="note" class="form-control"/>
              <p class="muted">What's this token for?</p>
            </fieldset>
            <input type="submit" class="btn btn-success" value="Generate token"/>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
}
